package org.zjsru.order.web;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestHeader;
import org.zjsru.order.pojo.Product;

@FeignClient(
        name = "product-service",
        fallback = ProductFeignClientFallback.class  /* 降级类*/
)
public interface ProductFeignClient {
    @PostMapping("/product/deduct")
    String deductStock(
            @RequestParam("productId") Long productId,
            @RequestParam("count") int count
    );

    @PostMapping("/product/restore-stock")
    String restoreStock(
            @RequestParam("productId") Long productId,
            @RequestParam("count") int count
    );

    @GetMapping("/product/detail/{productId}")
    Product getProductDetail(@PathVariable("productId") Long productId, @RequestHeader("X-User-Id") Long userId);
}
